//
//  ActiveApplyCell.m
//  KuWoCan
//
//  Created by hwd on 17/3/15.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "ActiveApplyCell.h"

@interface ActiveApplyCell ()

@property (nonatomic,strong) UILabel *oTimeParaLab;

@property (nonatomic,strong) UILabel *oStatusLab;

@property (nonatomic,strong) UIImageView *oStoreImgView;

@property (nonatomic,strong) UILabel *oStoreLab;

@property (nonatomic,strong) UILabel *oNumberLab;

@property (nonatomic,strong) UILabel *oTotalConstLab;

@end

@implementation ActiveApplyCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    //分割线视图
    UIView *separatorView = [UIView new];
    separatorView.backgroundColor = KwGaryColor;
    [self addSubview:separatorView];
    [separatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(@0);
        make.height.equalTo(@5);
    }];
    
    UILabel *oTimeConstLab = [UILabel new];
    oTimeConstLab.textColor = [UIColor grayColor];
    oTimeConstLab.font = [UIFont systemFontOfSize:13.0];
    oTimeConstLab.textAlignment = NSTextAlignmentLeft;
    oTimeConstLab.text = @"活动时间:";
    [self addSubview:oTimeConstLab];
    [oTimeConstLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.top.equalTo(separatorView.mas_bottom).offset(15);
        make.height.equalTo(@13);
    }];
    
    //parameter:订单时间
    _oTimeParaLab = [UILabel new];
    _oTimeParaLab.textColor = [UIColor grayColor];
    _oTimeParaLab.font = [UIFont systemFontOfSize:13.0];
    _oTimeParaLab.textAlignment = NSTextAlignmentLeft;
    _oTimeParaLab.text = @"2017-02-24 14:20";
    [self addSubview:_oTimeParaLab];
    [_oTimeParaLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oTimeConstLab.mas_right).offset(10);
        make.top.equalTo(oTimeConstLab.mas_top);
        make.bottom.equalTo(oTimeConstLab.mas_bottom);
    }];
    
    //parameter:订单状态
    _oStatusLab = [UILabel new];
    _oStatusLab.textColor = [UIColor orangeColor];
    _oStatusLab.font = [UIFont systemFontOfSize:12.5];
    _oStatusLab.textAlignment = NSTextAlignmentRight;
    _oStatusLab.text = @"待审批";
    [self addSubview:_oStatusLab];
    [_oStatusLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-15);
        make.centerY.mas_equalTo(oTimeConstLab.centerY);
        make.height.equalTo(oTimeConstLab.mas_height);
    }];
    
    UIView *lineView = [UIView new];
    lineView.backgroundColor = KwColor(@"#eeeeee");
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oTimeConstLab.mas_left);
        make.right.equalTo(@0);
        make.top.equalTo(oTimeConstLab.mas_bottom).offset(10);
        make.height.equalTo(@1.5);
    }];
    
    _oStoreImgView = [[UIImageView alloc] init];
    _oStoreImgView.image = [UIImage imageNamed:@"kuwo_logo"];
    [self addSubview:_oStoreImgView];
    [_oStoreImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@20);
        make.top.equalTo(lineView.mas_bottom).offset(17.5);
        make.height.width.equalTo(@58);
        make.bottom.equalTo(@-17.5);
    }];
    
    //parameter:
    _oStoreLab = [UILabel new];
    _oStoreLab.textColor = [UIColor blackColor];
    _oStoreLab.font = [UIFont systemFontOfSize:16*screenW_6];
    _oStoreLab.textAlignment = NSTextAlignmentLeft;
    _oStoreLab.text = @"活动: 通路奖励";
    [self addSubview:_oStoreLab];
    [_oStoreLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineView.mas_bottom).offset(25);
        make.left.equalTo(_oStoreImgView.mas_right).offset(20);
        make.right.equalTo(self).offset(-55);
        make.height.equalTo(@17);
    }];
    
    //parameter:
    _oNumberLab = [UILabel new];
    _oNumberLab.textColor = [UIColor grayColor];
    _oNumberLab.font = [UIFont systemFontOfSize:14.0*screenW_6];
    _oNumberLab.textAlignment = NSTextAlignmentLeft;
    _oNumberLab.text = @"活动费用: ¥";
    [self addSubview:_oNumberLab];
    [_oNumberLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_oStoreLab.mas_left);
        make.height.equalTo(@40);
        make.top.equalTo(_oStoreLab.mas_bottom).offset(0);
    }];
    
    _oTotalConstLab = [UILabel new];
    _oTotalConstLab.textColor = [UIColor grayColor];
    _oTotalConstLab.font = [UIFont systemFontOfSize:14.0*screenW_6];
    _oTotalConstLab.textAlignment = NSTextAlignmentLeft;
    _oTotalConstLab.text = @"销售额: ¥";
    [self addSubview:_oTotalConstLab];
    [_oTotalConstLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_oNumberLab.mas_right).offset(15);
        make.height.equalTo(@40);
        make.top.equalTo(_oNumberLab.mas_top);
    }];
    _oTotalConstLab.numberOfLines = 0;
}

- (void)setModel:(SAListModel *)model
{
    _oTimeParaLab .text = model.createDate;
    if (model.approvalStatus)
    {
        _oStatusLab.text = [Constants getSaleApplyStatusWithApprovalStatus:model.approvalStatus approvalType:model.approvalType];
    }
    if (model.examineStatus)
    {
        _oStatusLab.text = [Constants getSaleCheckStatusWithApprovalStatus:model.examineStatus approvalType:model.approvalType];
    }
    
    _oStoreLab.text = model.name;
    _oNumberLab.text = [NSString stringWithFormat:@"费效比率: %@%%",model.ratio];
    _oTotalConstLab.text = [NSString stringWithFormat:@"销售额: ￥%.2f", [model.salesVolume floatValue]];
}

- (void)setProDisModel:(ProductDisplayListModel *)proDisModel
{
    _oTimeParaLab .text = proDisModel.createDate;
    if (proDisModel.approvalStatus)
    {
        _oStatusLab.text = [Constants getSaleApplyStatusWithApprovalStatus:proDisModel.approvalStatus approvalType:proDisModel.approvalType];
    }
    if (proDisModel.examineStatus)
    {
        _oStatusLab.text = [Constants getSaleCheckStatusWithApprovalStatus:proDisModel.examineStatus approvalType:proDisModel.approvalType];
    }
    
    _oStoreLab.text = proDisModel.name;
    _oNumberLab.text = [NSString stringWithFormat:@"费效比率: %@%%",proDisModel.ratio];
    _oTotalConstLab.text = [NSString stringWithFormat:@"销售额: ￥%.2f", [proDisModel.salesVolume floatValue]];
}

- (void)setECModel:(EnterCostListModel *)ECModel
{
    _oTimeParaLab .text = ECModel.createDate;
    if (ECModel.approvalStatus)
    {
        _oStatusLab.text = [Constants getSaleApplyStatusWithApprovalStatus:ECModel.approvalStatus approvalType:ECModel.approvalType];
    }
    if (ECModel.examineStatus)
    {
        _oStatusLab.text = [Constants getSaleCheckStatusWithApprovalStatus:ECModel.examineStatus approvalType:ECModel.approvalType];
    }
    
    _oStoreLab.text = [NSString stringWithFormat:@"超市名称: %@",ECModel.name];
    _oNumberLab.text = [NSString stringWithFormat:@"费用总计:￥%.0f元", [ECModel.totalExpenses floatValue]];
    _oTotalConstLab.text = [NSString stringWithFormat:@"门店数量:%.0f",[ECModel.storeNumber floatValue]];

}

- (void)setOCModel:(OtherCostListModel *)OCModel
{
    _oTimeParaLab .text = OCModel.createDate;
    if (OCModel.approvalStatus)
    {
        _oStatusLab.text = [Constants getSaleApplyStatusWithApprovalStatus:OCModel.approvalStatus approvalType:OCModel.approvalType];
    }
    if (OCModel.examineStatus)
    {
        _oStatusLab.text = [Constants getSaleCheckStatusWithApprovalStatus:OCModel.examineStatus approvalType:OCModel.approvalType];
    }
    
    _oStoreLab.text = [NSString stringWithFormat:@"主旨: %@",OCModel.title];
    _oNumberLab.text = [NSString stringWithFormat:@"费用: ¥%.2f",[OCModel.costs floatValue]];
    _oTotalConstLab.text = [NSString stringWithFormat:@"说明: %@",OCModel.explains];
}


@end
